package vn.demand.dragon.model.business
{
	import mx.rpc.AsyncToken;
	import mx.rpc.IResponder;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;

	public class LoadReferenceDetailsDelegate 
	{
		private var responder : IResponder;
		private var service : HTTPService;

		public function LoadReferenceDetailsDelegate(result:Function, fault:Function) 
		{
			// constructor will store a reference to the service we're going to call
			this.service = new HTTPService();
			this.service.url = "http://dev.dragon.com/index.php?m=projects&a=reference_details&suppressHeaders=1";
			this.service.resultFormat = 'e4x';
			this.service.addEventListener(ResultEvent.RESULT, result);
			this.service.addEventListener(FaultEvent.FAULT, fault);
		}

		public function loadReference(project_id:int) : void 
		{
			var token:AsyncToken = service.send({'project_id': project_id});
			token.action = 'loadReference::' + project_id;
		}
		
		public function loadReferenceByCode(projectCode:String) : void 
		{
			var token:AsyncToken = service.send({'project_iso_code': projectCode});
			token.action = 'loadReference::' + projectCode;
		}
	}
}